<template>
  <div>
    <el-tag
      v-for="tag in tags"
      :key="tag[keyField]"
    >
      {{ tag[valueField] }}
    </el-tag>
  </div>
</template>

<script>
export default {
  name: 'IkTableRadioTag',
  props: {
    value: {
      type: String,
      default: ''
    },
    keyField: {
      type: String,
      default: ''
    },
    valueField: {
      type: String,
      default: ''
    },
    options: {
      type: Array,
      default: function() {
        return []
      }
    }
  },
  data() {
    return {
      val: []
    }
  },
  computed: {
    tags: function() {
      const $this = this
      const tagsArray = []
      for (const item in $this.options) {
        // 如果存在
        if ($this.value === $this.options[item][$this.keyField]) {
          tagsArray.push($this.options[item])
        }
      }
      return tagsArray
    }
  },
  // 如果value为空，取默认值
  created() {
  },
  methods: {
  }
}
</script>

<style lang="scss" >
.el-tag{
  margin-left: 10px;
}
</style>
